/**
 * @file AITeachingAssistant.vue
 * @description 智能教学助手功能页面
 * @created 2024-03-20
 */

<template>
  <div class="ai-teaching-assistant">
    <div class="page-header">
      <h2>智能教学助手</h2>
    </div>

    <!-- 功能区域 -->
    <div class="features-grid">
      <!-- 智能备课 -->
      <div class="feature-section">
        <h3>智能备课</h3>
        <div class="tool-card">
          <div class="tool-header">
            <span class="icon">📚</span>
            <h4>课程设计助手</h4>
          </div>
          <p>基于教学目标智能生成教案和课件</p>
          <button class="use-btn">使用工具</button>
        </div>
      </div>

      <!-- 智能答疑 -->
      <div class="feature-section">
        <h3>智能答疑</h3>
        <div class="chat-interface">
          <div class="chat-messages">
            <div class="message" v-for="msg in messages" :key="msg.id"
                 :class="msg.type">
              <div class="message-content">{{ msg.content }}</div>
              <div class="message-time">{{ msg.time }}</div>
            </div>
          </div>
          <div class="chat-input">
            <input type="text" placeholder="输入您的问题...">
            <button>发送</button>
          </div>
        </div>
      </div>

      <!-- 教学分析 -->
      <div class="feature-section">
        <h3>教学分析</h3>
        <div class="analysis-card">
          <div class="analysis-item" v-for="item in analysisData" :key="item.label">
            <div class="label">{{ item.label }}</div>
            <div class="value">{{ item.value }}</div>
            <div class="trend" :class="item.trend > 0 ? 'up' : 'down'">
              {{ item.trend > 0 ? '↑' : '↓' }}{{ Math.abs(item.trend) }}%
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

// 聊天消息数据
const messages = ref([
  {
    id: 1,
    type: 'received',
    content: '您好！我是AI教学助手，有什么可以帮您的吗？',
    time: '10:00'
  },
  {
    id: 2,
    type: 'sent',
    content: '我需要一份Python基础课程的教案',
    time: '10:01'
  }
])

// 分析数据
const analysisData = ref([
  {
    label: '课堂互动率',
    value: '85%',
    trend: 5
  },
  {
    label: '知识点掌握度',
    value: '92%',
    trend: 3
  },
  {
    label: '学生参与度',
    value: '88%',
    trend: -2
  }
])
</script>

<style scoped>
.ai-teaching-assistant {
  padding: 24px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.feature-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tool-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.use-btn {
  width: 100%;
  padding: 8px;
  background: #1890ff;
  color: white;
  border: none;
  border-radius: 4px;
  margin-top: 12px;
  cursor: pointer;
}

.chat-interface {
  height: 400px;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.message {
  margin-bottom: 12px;
  max-width: 80%;
}

.message.received {
  margin-right: auto;
}

.message.sent {
  margin-left: auto;
  background: #1890ff;
  color: white;
}

.message-content {
  padding: 8px 12px;
  border-radius: 8px;
  background: white;
}

.message-time {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

.chat-input {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.chat-input input {
  flex: 1;
  padding: 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
}

.analysis-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.analysis-item {
  text-align: center;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.analysis-item .value {
  font-size: 24px;
  font-weight: bold;
  color: #1890ff;
  margin: 8px 0;
}

.trend.up {
  color: #52c41a;
}

.trend.down {
  color: #ff4d4f;
}
</style> 